﻿using System.Data.Entity;
using DomainModel;
using ObjectModel;

namespace DataAccess
{
    public class DomainModel : DbContext
    {
        public DomainModel() : base("Forum")
        {}

        public DbSet<Section> Sections { get; set; }

        public DbSet<Thread> Threads { get; set; }

        public DbSet<Post> Posts { get; set; }

        public DbSet<User> Users { get; set; }

        public DbSet<UserRole> Roles { get; set; }

        public DbSet<Application> Applications { get; set; }

        public DbSet<ConfigurationItem> ConfigurationItems { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Configurations.Add(new PostConfiguration());
            modelBuilder.Configurations.Add(new SectionConfiguration());
            modelBuilder.Configurations.Add(new ThreadConfiguration());
            modelBuilder.Configurations.Add(new UserConfiguration());
            modelBuilder.Configurations.Add(new RoleConfiguration());
        }
    }
}
